/**
 * @author zyj
 * @date 2022年06月09日 16:06
 */
public class 打印顺序是12A34B {
    public static void main(String[] args) {
        Object obj = new Object();
        new Thread(new ShuZhi(obj)).start();
        new Thread(new ZiMu(obj)).start();
    }
}

class ShuZhi implements Runnable{
    private Object obj;

    public ShuZhi(Object obj){
        this.obj = obj;
    }

    @Override
    public void run() {
        synchronized (obj){
            for (int i = 1; i <= 52; i++) {
                System.out.println(i);
                if (i % 2 == 0){
                    obj.notifyAll();
                    try {
                        obj.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
            obj.notifyAll();
        }
    }
}

class ZiMu implements Runnable{

    private Object obj;

    public ZiMu(Object obj){
        this.obj = obj;
    }
    @Override
    public void run() {
        synchronized (obj){
            for (int i = 0; i < 26 ; i++) {
                System.out.println((char) (i + 'A'));
                obj.notifyAll();
                try {
                    obj.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }
    }
}
